/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

const rules = {
  phone: {
    // 手机号
    code: 3001,
    pattern: /^1[2-9]{1}[0-9]{1}\d{8}$/,
    message: "手机号码输入错误",
    tag: "手机号",
  },
  telPhone: {
    // 电话号码
    code: 3002,
    pattern: /^(0\d{2,3}(-|\s?))?[2-9]{1}\d{6,7}((-|\s?)\d{1,4})?$/,
    message: "电话号码输入错误",
    tag: "电话号码",
  },
  contact: {
    // 联系方式
    code: 30012,
    pattern: /^1\d{10}$|^(0\d{2,3}(-|\s?))?[2-9]{1}\d{6,7}((-|\s?)\d{1,4})?$/,
    message: "请输入正确的手机或固话",
    tag: "联系方式",
  },
  decimal2: {
    // 支持小数 2位
    code: 3011,
    type: "number",
    pattern: /^\d+(?:\.\d{1,2})?$/,
    message: "数字且最多允许两位小数",
  },
  waybillNum: {
    // 运单号
    code: 3014,
    pattern: /^[0-9a-zA-Z\-]{8,30}$/,
    message: "单号不正确",
    tag: "单号",
  },
  bh: {
    // 取件码
    code: 3016,
    pattern: /^([\da-zA-Z]|-(?!-)){1,10}$/,
    message: "取件码只允许字母与数字组合且数字结尾，允许单横线连接",
    tag: "取件码",
  },
  password: {
    // 密码
    code: 3017,
    pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,15}$/,
    message: "请输入英文字母加数字，且位数为8-15位的密码",
    tag: "密码",
  },
};

const { phone, telPhone, contact, decimal2, waybillNum, bh, password } = rules;

export { rules as default, phone, telPhone, contact, decimal2, waybillNum, bh, password };
